﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FileMonSync
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            HideWindow();
        }

        private void HideWindow() {
            this.Visible = false;
            this.ShowInTaskbar = false;
            this.WindowState = FormWindowState.Minimized;
            this.Hide();
        }

        private void ShowWindow() {
            this.Visible = true;
            this.ShowInTaskbar = true;
            this.WindowState = FormWindowState.Normal;
            this.Show();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //if (this.WindowState == FormWindowState.Minimized)
            //{
            //    ShowWindow();
            //}
            //else
            //{
            //    HideWindow();
            //}
        }

        private void MainForm_Shown(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        private void MainForm_SizeChanged(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Hide();
            }
        }

        private void exitMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void restoreMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menu = sender as ToolStripMenuItem;
            EventBus.dispatchTrayMenuEventHandler(sender,new TrayMenuEventArgs(TrayMenuEventArgs.TrayMenuType.RESTORE));
        }

        private void backupMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menu = sender as ToolStripMenuItem;
            EventBus.dispatchTrayMenuEventHandler(sender, new TrayMenuEventArgs(TrayMenuEventArgs.TrayMenuType.BACKUP));
        }
    }
}
